import { defineStore } from 'pinia'

export const useTeamStore = defineStore('team', {
  state: () => ({
    teams: [
      {
        id: 1,
        name: '精密机械加工班组',
        type: '维修',
        leader: '王建国',
        members: 15,
        createdAt: '2023-05-15',
        collected: true,
        joined: true,
        intro: '我们是一支专业的空调维修团队，专注于各类品牌空调的安装、维修和保养服务。团队成员均持有专业资质证书，经验丰富，服务态度好。我们的服务区域覆盖全龙潭街道及周边社区，提供7×24小时快速响应服务。',
        memberList: [
          { id: 1, name: '陈志明', role: '高级空调维修技师', leader: true, avatar: 'https://randomuser.me/api/portraits/men/32.jpg' },
          { id: 2, name: '张建国', role: '空调维修技师', leader: false, avatar: 'https://randomuser.me/api/portraits/men/33.jpg' },
          { id: 3, name: '王小龙', role: '空调维修学徒', leader: false, avatar: 'https://randomuser.me/api/portraits/men/34.jpg' },
          { id: 4, name: '李维修', role: '空调安装技师', leader: false, avatar: 'https://randomuser.me/api/portraits/men/35.jpg' },
        ],
        teamStats: {
          members: [
            { name: '张建国', type: '维修', time: '2.5h', ontime: 95, tasks: 17, efficiency: 0.9, score: 4.8 },
            { name: '李明辉', type: '安装', time: '3.2h', ontime: 88, tasks: 19, efficiency: 0.85, score: 4.6 },
            { name: '王志国', type: '维护', time: '2.1h', ontime: 90, tasks: 13, efficiency: 0.8, score: 4.7 },
            { name: '赵国强', type: '维修', time: '2.8h', ontime: 80, tasks: 15, efficiency: 0.7, score: 4.5 },
          ]
        }
      },
      {
        id: 2,
        name: '电气设备维修班组',
        type: '维修',
        leader: '李志明',
        members: 12,
        createdAt: '2023-06-20',
        collected: false,
        joined: true,
        intro: '负责公司所有电气设备的日常维护和故障抢修，团队成员经验丰富，响应迅速，保障生产线安全运行。',
        memberList: [
          { id: 5, name: '李志明', role: '组长', leader: true, avatar: 'https://randomuser.me/api/portraits/men/36.jpg' },
          { id: 6, name: '王五', role: '电气维修技师', leader: false, avatar: 'https://randomuser.me/api/portraits/men/37.jpg' },
          { id: 7, name: '赵六', role: '电气维修学徒', leader: false, avatar: 'https://randomuser.me/api/portraits/men/38.jpg' },
        ],
        teamStats: {
          members: [
            { name: '李志明', type: '维修', time: '2.7h', ontime: 92, tasks: 15, efficiency: 0.88, score: 4.7 },
            { name: '王五', type: '维修', time: '2.9h', ontime: 85, tasks: 12, efficiency: 0.8, score: 4.5 },
            { name: '赵六', type: '维修', time: '2.4h', ontime: 90, tasks: 10, efficiency: 0.82, score: 4.6 },
          ]
        }
      },
      {
        id: 3,
        name: '品质检验班组',
        type: '保养',
        leader: '张晓燕',
        members: 8,
        createdAt: '2023-07-01',
        collected: true,
        joined: true,
        intro: '主要负责产品出厂前的品质检验，严格把控每一道工序，确保产品质量达标。',
        memberList: [
          { id: 8, name: '张晓燕', role: '组长', leader: true, avatar: 'https://randomuser.me/api/portraits/women/32.jpg' },
          { id: 9, name: '李敏', role: '检验员', leader: false, avatar: 'https://randomuser.me/api/portraits/women/33.jpg' },
        ],
        teamStats: {
          members: [
            { name: '张晓燕', type: '保养', time: '2.2h', ontime: 97, tasks: 11, efficiency: 0.93, score: 4.9 },
            { name: '李敏', type: '保养', time: '2.5h', ontime: 90, tasks: 9, efficiency: 0.85, score: 4.7 },
          ]
        }
      },
      {
        id: 4,
        name: '生产装配班组',
        type: '安装',
        leader: '刘德华',
        members: 20,
        createdAt: '2023-08-01',
        collected: false,
        joined: true,
        intro: '承担生产线装配任务，团队协作高效，能快速完成各类产品的组装和调试。',
        memberList: [
          { id: 10, name: '刘德华', role: '组长', leader: true, avatar: 'https://randomuser.me/api/portraits/men/39.jpg' },
          { id: 11, name: '王强', role: '装配工', leader: false, avatar: 'https://randomuser.me/api/portraits/men/40.jpg' },
        ],
        teamStats: {
          members: [
            { name: '刘德华', type: '安装', time: '3.0h', ontime: 89, tasks: 18, efficiency: 0.87, score: 4.8 },
            { name: '王强', type: '安装', time: '3.3h', ontime: 84, tasks: 14, efficiency: 0.8, score: 4.6 },
          ]
        }
      },
      {
        id: 5,
        name: '高层建筑安装团队',
        type: '安装',
        leader: '未知',
        members: 12,
        createdAt: '2023-06-20',
        collected: false,
        joined: false,
        intro: '专注于高层建筑设备的安装与调试，拥有丰富的高空作业经验。',
        memberList: [
          { id: 12, name: '高飞', role: '组长', leader: true, avatar: 'https://randomuser.me/api/portraits/men/41.jpg' },
          { id: 13, name: '李工', role: '安装技师', leader: false, avatar: 'https://randomuser.me/api/portraits/men/42.jpg' },
        ],
        teamStats: {
          members: [
            { name: '高飞', type: '安装', time: '3.1h', ontime: 90, tasks: 13, efficiency: 0.86, score: 4.7 },
            { name: '李工', type: '安装', time: '3.4h', ontime: 82, tasks: 11, efficiency: 0.78, score: 4.5 },
          ]
        }
      },
      {
        id: 6,
        name: '设备保养精英组',
        type: '保养',
        leader: '未知',
        members: 8,
        createdAt: '2023-07-01',
        collected: true,
        joined: false,
        intro: '负责公司所有设备的定期保养和维护，延长设备使用寿命。',
        memberList: [
          { id: 14, name: '赵保', role: '组长', leader: true, avatar: 'https://randomuser.me/api/portraits/men/43.jpg' },
          { id: 15, name: '钱养', role: '保养技师', leader: false, avatar: 'https://randomuser.me/api/portraits/men/44.jpg' },
        ],
        teamStats: {
          members: [
            { name: '赵保', type: '保养', time: '2.3h', ontime: 95, tasks: 10, efficiency: 0.9, score: 4.8 },
            { name: '钱养', type: '保养', time: '2.6h', ontime: 88, tasks: 8, efficiency: 0.82, score: 4.6 },
          ]
        }
      },
      {
        id: 7,
        name: '应急维修先锋队',
        type: '维修',
        leader: '未知',
        members: 10,
        createdAt: '2023-07-15',
        collected: false,
        joined: true,
        intro: '专门负责突发故障的应急抢修，24小时待命，保障生产安全。',
        memberList: [
          { id: 16, name: '孙应', role: '组长', leader: true, avatar: 'https://randomuser.me/api/portraits/men/45.jpg' },
          { id: 17, name: '周急', role: '维修技师', leader: false, avatar: 'https://randomuser.me/api/portraits/men/46.jpg' },
        ],
        teamStats: {
          members: [
            { name: '孙应', type: '维修', time: '2.9h', ontime: 87, tasks: 16, efficiency: 0.83, score: 4.6 },
            { name: '周急', type: '维修', time: '2.7h', ontime: 85, tasks: 12, efficiency: 0.8, score: 4.5 },
          ]
        }
      },
      {
        id: 8,
        name: '新设备安装组',
        type: '安装',
        leader: '未知',
        members: 14,
        createdAt: '2023-08-01',
        collected: false,
        joined: false,
        intro: '负责新购设备的安装与调试，确保设备正常运行。',
        memberList: [
          { id: 18, name: '吴新', role: '组长', leader: true, avatar: 'https://randomuser.me/api/portraits/men/47.jpg' },
          { id: 19, name: '郑装', role: '安装技师', leader: false, avatar: 'https://randomuser.me/api/portraits/men/48.jpg' },
        ],
        teamStats: {
          members: [
            { name: '吴新', type: '安装', time: '3.2h', ontime: 91, tasks: 15, efficiency: 0.88, score: 4.7 },
            { name: '郑装', type: '安装', time: '3.5h', ontime: 80, tasks: 13, efficiency: 0.76, score: 4.4 },
          ]
        }
      },
      {
        id: 9,
        name: '预防性保养小组',
        type: '保养',
        leader: '未知',
        members: 6,
        createdAt: '2023-08-15',
        collected: true,
        joined: false,
        intro: '以预防为主，定期检查和维护设备，减少故障发生。',
        memberList: [
          { id: 20, name: '冯防', role: '组长', leader: true, avatar: 'https://randomuser.me/api/portraits/men/49.jpg' },
          { id: 21, name: '陈养', role: '保养技师', leader: false, avatar: 'https://randomuser.me/api/portraits/men/50.jpg' },
        ],
        teamStats: {
          members: [
            { name: '冯防', type: '保养', time: '2.4h', ontime: 93, tasks: 9, efficiency: 0.89, score: 4.8 },
            { name: '陈养', type: '保养', time: '2.7h', ontime: 86, tasks: 7, efficiency: 0.81, score: 4.5 },
          ]
        }
      }
    ],
    teamStats: {
      members: [
        { name: '张建国', type: '维修', time: '2.5h', ontime: 95, tasks: 17, efficiency: 0.9, score: 4.8 },
        { name: '李明辉', type: '安装', time: '3.2h', ontime: 88, tasks: 19, efficiency: 0.85, score: 4.6 },
        { name: '王志国', type: '维护', time: '2.1h', ontime: 90, tasks: 13, efficiency: 0.8, score: 4.7 },
        { name: '赵国强', type: '维修', time: '2.8h', ontime: 80, tasks: 15, efficiency: 0.7, score: 4.5 },
      ]
    },
    applications: [
      {
        id: 1,
        name: '陈明宇',
        avatar: 'https://randomuser.me/api/portraits/men/32.jpg',
        time: '2024-03-15 14:30',
        team: '精密机械加工班组',
        reason: '作为一名拥有5年经验的前端开发工程师，精通Vue、React等主流…',
        status: 'pending'
      },
      {
        id: 2,
        name: '林雨晴',
        avatar: 'https://randomuser.me/api/portraits/women/32.jpg',
        time: '2024-03-15 10:15',
        team: '品质检验班组',
        reason: '毕业于知名艺术院校，3年UI设计经验，擅长移动端界面设计，熟练…',
        status: 'pending'
      },
      {
        id: 3,
        name: '王建国',
        avatar: 'https://randomuser.me/api/portraits/men/33.jpg',
        time: '2024-03-14 16:45',
        team: '电气设备维修班组',
        reason: '8年后端开发经验，精通Java、Spring Boot、微服务架构，具备大…',
        status: 'pending'
      }
    ]
  }),
  actions: {
    toggleCollect(id) {
      const team = this.teams.find(t => t.id === id)
      if (team) team.collected = !team.collected
    },
    joinTeam(id) {
      const team = this.teams.find(t => t.id === id)
      if (team) team.joined = true
    },
    unjoinTeam(id) {
      const team = this.teams.find(t => t.id === id)
      if (team) team.joined = false
    }
  }
}) 